// compile:
// run:
#include <iostream>

using namespace std;

#include <iostream>
#include <tuple>
auto get_student(int id) {
  // 返回类型被推断为 std::tuple<double, char, std::string>
  if (id == 0) return std::make_tuple(3.8, 'A', "张三");
  if (id == 1) return std::make_tuple(2.9, 'C', "李四");
  if (id == 2) return std::make_tuple(1.7, 'D', "王五");
  return std::make_tuple(0.0, 'D', "null");
  // 如果只写 0 会出现推断错误, 编译失败
}
int main() {
  auto student = get_student(0);
  std::cout << "ID: 0, "
            << "GPA: " << std::get<0>(student) << ", "
            << "成绩: " << std::get<1>(student) << ", "
            << "姓名: " << std::get<2>(student) << '\n';
  double gpa;
  char grade;
  std::string name;
  // 元组进行拆包
  std::tie(gpa, grade, name) = get_student(1);
  std::cout << "ID: 1, "
            << "GPA: " << gpa << ", "
            << "成绩: " << grade << ", "
            << "姓名: " << name << '\n';
  auto tmp = get_student(2);
  auto new_tuple = std::tuple_cat(tmp, get_student(0), get_student(1));

  std::cout << "ID: 2, "
            << "GPA: " << std::get<0>(new_tuple) << ", "
            << "成绩: " << std::get<1>(new_tuple) << ", "
            << "姓名: " << std::get<2>(new_tuple) << '\n';
}